<template>
    <!-- 单个商品卡片 -->
    <li class="contentGoods"  :key="item.id" @click=" test1(item.id)">
        <img :src="item.listPicUrl" class="contentGoodImg">
        <div class="contentGoodText">
            <!-- 商标 -->
            <img :src="itemLogo && itemLogo.logoUrl" class="logo1" v-for="(itemLogo, index) in item.preLogo" :key="index">
            {{ item.name }}
        </div>
        <!-- 红包 -->
        <div class="contentGoodRedpaper" v-for="itemTag in item.itemTagList" :key="itemTag.itemId">
            <img src="https://yanxuan.nosdn.127.net/static-union/166909947513c0c8.png" class="logo2">
            <span>{{ itemTag && itemTag.name }}</span>
        </div>
        <!-- 价格区 -->
        <div class="contentGoodPrice">
            {{ item.finalPriceInfoVO.priceInfo.finalPrice &&
                item.finalPriceInfoVO.priceInfo.finalPrice.prefix }}¥<span
                v-if="item.finalPriceInfoVO.priceInfo.finalPrice && item.finalPriceInfoVO.priceInfo.finalPrice.price"><span
                    class="text1">{{ item.finalPriceInfoVO.priceInfo.finalPrice &&
                        item.finalPriceInfoVO.priceInfo.finalPrice.price }}</span>{{
        item.finalPriceInfoVO.priceInfo.finalPrice && item.finalPriceInfoVO.priceInfo.finalPrice.suffix
    }}</span><span v-else class="text1">{{ item.finalPriceInfoVO.priceInfo &&
    item.finalPriceInfoVO.priceInfo.basicPrice }}</span>
            <del class="text2" v-if="item.finalPriceInfoVO.priceInfo && item.finalPriceInfoVO.priceInfo.counterPrice">¥{{
                item.finalPriceInfoVO.priceInfo && item.finalPriceInfoVO.priceInfo.counterPrice }}</del>
        </div>
        <!-- 活动区 -->
        <div class="contentGoodActivity"
            :class="{ showWidth: item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.title }"
            v-if="item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.content">
            <img src="./img/b268d0d2f46c41d3b3edf5fa33eea3de.png" class="logo3">
            <div class="Text3">
                <span v-if="item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.title">{{
                    item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.title }}</span>
                <span v-else>{{ item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.content }}</span>
            </div>
            <div class="Text4" v-if="item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.title">
                {{ item.finalPriceInfoVO.banner && item.finalPriceInfoVO.banner.content }}
            </div>
        </div>
        <!-- 置顶图片 -->
        <img :src="item.topLogo && item.topLogo.logoUrl" class="logo4" v-if="item.topLogo && item.topLogo.logoUrl">
    </li>
</template>

<script lang="ts">
import { defineComponent } from "vue"
export default defineComponent({
    name: '',
})
</script>

<script lang="ts" setup>
import type { IgoodCardItemList } from "@/api/homeApi"
import { useRouter } from "vue-router";
import { computed } from "vue";
const router = useRouter()
const props = defineProps<{
    item: IgoodCardItemList,
}>()

const item = computed(() => {
    return props.item
})

function test1(Id:number){
    console.log('a');
    router.push({
        name:'GoodsDetails',
        query:{
            Id:Id
        }
    })
}

</script>

<style lang="less" scoped>
// 单个商品卡片
.contentGoods {
    position: relative;
    width: 172.5px;
    padding-left: 10px;
    padding-bottom: 26px;

    // 商品图片
    .contentGoodImg {
        width: 100%;
        height: 172.5px;
        border-radius: 10px;
    }

    .contentGoodText {
        font-size: 14px;
        line-height: 20px;

        .logo1 {
            height: 15px;
            position: relative;
            top: 2px;
        }

    }

    .contentGoodRedpaper {
        border: 1px solid #d6d6d6;
        border-radius: 10px;
        width: 62px;
        height: 15px;
        line-height: 15px;
        padding-left: 3px;
        vertical-align: middle;
        margin-bottom: 10px;

        .logo2 {
            height: 10px;
            position: relative;
            top: 1px;
        }
    }

    .contentGoodPrice {
        color: #fa1e32;
        height: 30px;
        font-weight: bolder;

        .text1 {
            font-size: 20px;
        }

        .text2 {
            font-weight: normal;
            color: rgb(153, 153, 153);
        }
    }

    .contentGoodActivity {
        position: relative;
        height: 23px;
        align-items: center;
        padding: 0 3px;
        font-weight: bolder;
        border-radius: 10px;
        background-color: rgb(255, 233, 235);
        display: inline-block;

        .Text3 {
            display: inline-block;
            color: white;
            padding: 2px 5px;
            border-radius: 10px;
            background-color: rgb(350, 30, 50);
        }

        .Text4 {
            display: inline-block;
            padding: 0 3px;
            color: rgb(250, 30, 50);
        }

        .logo3 {
            position: absolute;
            top: -6px;
            left: 13px;
        }
    }

    .logo4 {
        position: absolute;
        width: 52.5px;
        height: 27px;
        top: 5px;
        right: 5px;
    }
}



/* 特殊 */
.showNO {
    display: none;
}

.showWidth {
    width: 100%;
}

::v-deep .van-swipe__indicator {
    border-radius: 0;
    width: 20px;
    height: 2px;
}
</style>